home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 4⁄27⁄90 / 0105-Dynamic instanciatio-Apr90 next >
Encoding:
Text File  |  1990-04-23  |  978 b   |  36 lines  |  [TEXT/GEOL]

  1. Item    4450622                         23-April-90        08:38PDT
  2.  
  3. From:   NAUTIL                          France - Dev, Nautil Info Lyon,IDV
  4.  
  5. To:     CPLUS.APPLE$                    C++ Interest List--Apple Employees
  6.         CPLUS.DEV$                      C++ Interest List--Developers
  7.  
  8. Sub:    Dynamic instanciation
  9.  
  10. Hello,
  11.  
  12. How can be done "dynamic instanciation" in C++? I would like to create an
  13. object sometime of class A, sometime of class B, sometime of class C, etc.:
  14.  
  15. switch(sometime) {
  16.     case makeA:
  17.         x = new A;
  18.         break;
  19.     case makeB:
  20.         x = new B;
  21.         break;
  22.     case makeC:
  23.         x = new C;
  24.         break;
  25.     …
  26. }
  27. Problem: A, B, C, etc... are not defined when this code is compiled.
  28.  
  29. With Object Pascal one can use the "Clone" method or the "InstanceBy…" methods.
  30. What are equivalent instructions for "not PascalObject" C++ classes?
  31. ("sometime" could be an ID, an object member or anything else.)
  32.  
  33. Thanks,
  34. Etienne Vautherin
  35.  
  36.